<?php

/**
 * 数字验证码
 */
namespace lico\Tool\Captcha;

use lico\Tool\Helper;

class Digit
{

    protected $code;
    protected $data;
    protected $config;

    public function __construct($config)
    {
        $this->config = $config;
    }

    /**
     * 验证码
     */
    public function getCode($length = '')
    {
        if (is_null($this->code) && $length) {
            $this->code = Helper::getRandStr($length, 'number');
            $this->data = $this->code;
        }
        return $this->code;
    }

    /**
     * 干扰点
     */
    public function getSpot($length)
    {
        return Helper::getRandStr($length, 'number');
    }

    /**
     * 获取校验值
     */
    public function getData()
    {
        return $this->data;
    }
}
